///////////////////////////////////////////////////////////////////////////
// Copyright 2009 Arabic Game Developer Network, All rights reserved
// www.agd-online.com - info@agdn-online.com
//
// File: sdlinput.cpp
// Description:
//
///////////////////////////////////////////////////////////////////////////

// This file is part of kvalleyX.
// 
// kvalleyX is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// kvalleyX is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with kvalleyX.  If not, see <http://www.gnu.org/licenses/>.

#include "sdlinput.h"
#include <iostream>

bool SDLInputManager::init()
{
	if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) != 0)
	{
		std::cerr << "ERROR: Could not initialize SDL Joystick subsystem: " <<
		SDL_GetError() << std::endl;
		return false;
	}
	// assign keys
	using namespace CoreLib;
 	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
 	(INPUTK_BACKSPACE, SDLK_BACKSPACE));
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_TAB, SDLK_TAB)); 		//	'\t'	tab
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_CLEAR, SDLK_CLEAR));		//	 		clear
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_RETURN, SDLK_RETURN));		//	'\r'	return
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_PAUSE, SDLK_PAUSE));		//		 	pause
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_ESCAPE, SDLK_ESCAPE));		//	'^['	escape
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_SPACE, SDLK_SPACE));		//	' '		space
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_EXCLAIM, SDLK_EXCLAIM));		//	'!'		exclaim
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_QUOTEDBL, SDLK_QUOTEDBL));	//	'"'		quotedbl
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_HASH, SDLK_HASH));		//	'#'		hash
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_DOLLAR, SDLK_DOLLAR));		//	'$'		dollar
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_AMPERSAND, SDLK_AMPERSAND));	//	'&'		ampersand
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_QUOTE, SDLK_QUOTE));		//	'''		quote
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_LEFTPAREN, SDLK_LEFTPAREN));	//	'('		left parenthesis
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_RIGHTPAREN, SDLK_RIGHTPAREN));	//	')'		rightparenthesis
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_ASTERISK, SDLK_ASTERISK));	//	'*'		asterisk
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_PLUS, SDLK_PLUS));		//	'+'		plus sign
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_COMMA, SDLK_COMMA));		//	','		comma
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_MINUS, SDLK_MINUS));		//	'-'		minus sign
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_PERIOD, SDLK_PERIOD));		//	'.'		period
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_SLASH, SDLK_SLASH));		//	'/'		forward slash
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_0, SDLK_0));			//	'0'		0
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_1, SDLK_1));			//	'1'		1
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_2, SDLK_2));			//	'2'		2
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_3, SDLK_3));			//	'3'		3
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_4, SDLK_4));			//	'4'		4
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_5, SDLK_5));			//	'5'		5
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_6, SDLK_6));			//	'6'		6
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_7, SDLK_7));			//	'7'		7
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_8, SDLK_8));			//	'8'		8
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_9, SDLK_9));			//	'9'		9
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_COLON, SDLK_COLON));		//	':'		colon
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_SEMICOLON, SDLK_SEMICOLON));	//	';'		semicolon
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_LESS, SDLK_LESS));		//	'<'		less-than sign
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_EQUALS, SDLK_EQUALS));		//	'='		equals sign
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_GREATER, SDLK_GREATER));		//	'>'		greater-thansign
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_QUESTION, SDLK_QUESTION));	//	'?'		question mark
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_AT, SDLK_AT));			//	'@'		at
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_LEFTBRACKET, SDLK_LEFTBRACKET));	//	'['		left bracket
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_BACKSLASH, SDLK_BACKSLASH));	//	'\'		backslash
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_RIGHTBRACKET, SDLK_RIGHTBRACKET));//	']'		rightbracket
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_CARET, SDLK_CARET));		//	'^'		caret
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_UNDERSCORE, SDLK_UNDERSCORE));	//	'_'		underscore
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_BACKQUOTE, SDLK_BACKQUOTE));	//	'`'		grave
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_a, SDLK_a));			//	'a'		a
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_b, SDLK_b));			//	'b'		b
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_c, SDLK_c));			//	'c'		c
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_d, SDLK_d));			//	'd'		d
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_e, SDLK_e));			//	'e'		e
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_f, SDLK_f));			//	'f'		f
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_g, SDLK_g));			//	'g'		g
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_h, SDLK_h));			//	'h'		h
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_i, SDLK_i));			//	'i'		i
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_j, SDLK_j));			//	'j'		j
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_k, SDLK_k));			//	'k'		k
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_l, SDLK_l));			//	'l'		l
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_m, SDLK_m));			//	'm'		m
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_n, SDLK_n));			//	'n'		n
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_o, SDLK_o));			//	'o'		o
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_p, SDLK_p));			//	'p'		p
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_q, SDLK_q));			//	'q'		q
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_r, SDLK_r));			//	'r'		r
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_s, SDLK_s));			//	's'		s
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_t, SDLK_t));			//	't'		t
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_u, SDLK_u));			//	'u'		u
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_v, SDLK_v));			//	'v'		v
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_w, SDLK_w));			//	'w'		w
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_x, SDLK_x));			//	'x'		x
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_y, SDLK_y));			//	'y'		y
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_z, SDLK_z));			//	'z'		z
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_DELETE, SDLK_DELETE));		//	'^?'	delete
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP0, SDLK_KP0));			//	 		keypad 0
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP1, SDLK_KP1));			//	 		keypad 1
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP2, SDLK_KP2));			//		 	keypad 2
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP3, SDLK_KP3));			//		 	keypad 3
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP4, SDLK_KP4));			//		 	keypad 4
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP5, SDLK_KP5));			//		 	keypad 5
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP6, SDLK_KP6));			//		 	keypad 6
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP7, SDLK_KP7));			//		 	keypad 7
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP8, SDLK_KP8));			//		 	keypad 8
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP9, SDLK_KP9));			//		 	keypad 9
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP_PERIOD, SDLK_KP_PERIOD));	//	'.'		keypad period
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP_DIVIDE, SDLK_KP_DIVIDE));	//	'/'		keypad divide
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP_MULTIPLY, SDLK_KP_MULTIPLY));	//	'*'	keypad multiply
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP_MINUS, SDLK_KP_MINUS));	//	'-'		keypad minus
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP_PLUS, SDLK_KP_PLUS));		//	'+'		keypad plus
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP_ENTER, SDLK_KP_ENTER));	//	'\r'	keypad enter
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_KP_EQUALS, SDLK_KP_EQUALS));	//	'='		keypad equals
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_UP, SDLK_UP));			//	 		up arrow
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_DOWN, SDLK_DOWN));		//	 		down arrow
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_RIGHT, SDLK_RIGHT));		//	 		right arrow
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_LEFT, SDLK_LEFT));		//	 		left arrow
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_INSERT, SDLK_INSERT));		//	 		insert
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_HOME, SDLK_HOME));		//	 		home
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_END, SDLK_END));			//	 		end
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_PAGEUP, SDLK_PAGEUP));		//	 		page up
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_PAGEDOWN, SDLK_PAGEDOWN));	//	 		page down
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F1, SDLK_F1));			//	 		F1
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F2, SDLK_F2));			//	 		F2
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F3, SDLK_F3));			//	 		F3
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F4, SDLK_F4));			//	 		F4
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F5, SDLK_F5));			//	 		F5
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F6, SDLK_F6));			//	 		F6
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F7, SDLK_F7));			//	 		F7
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F8, SDLK_F8));			//	 		F8
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F9, SDLK_F9));			//	 		F9
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F10, SDLK_F10));			//	 		F10
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F11, SDLK_F11));			//	 		F11
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F12, SDLK_F12));			//	 		F12
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F13, SDLK_F13));			//	 		F13
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F14, SDLK_F14));			//	 		F14
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_F15, SDLK_F15));			//	 		F15
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_NUMLOCK, SDLK_NUMLOCK));		//	 		numlock
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_CAPSLOCK, SDLK_CAPSLOCK));	//	 		capslock
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_SCROLLOCK, SDLK_SCROLLOCK));	//	 		scrollock
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_RSHIFT, SDLK_RSHIFT));		//	 		right shift
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_LSHIFT, SDLK_LSHIFT));		//	 		left shift
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_RCTRL, SDLK_RCTRL));		//	 		right ctrl
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_LCTRL, SDLK_LCTRL));		//	 		left ctrl
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_RALT, SDLK_RALT));		//	 		right alt
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_LALT, SDLK_LALT));		//	 		left alt
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_RMETA, SDLK_RMETA));		//	 		right meta
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_LMETA, SDLK_LMETA));		//	 		left meta
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_LSUPER, SDLK_LSUPER));		//	 		left windows key
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_RSUPER, SDLK_RSUPER));		//	 		right windows key
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_MODE, SDLK_MODE));		//	 		mode shift
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_HELP, SDLK_HELP));		//	 		help
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_PRINT, SDLK_PRINT));		//	 		print-screen
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_SYSREQ, SDLK_SYSREQ));		//	 		SysRq
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_BREAK, SDLK_BREAK));		//	 		break
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_MENU, SDLK_MENU));		//	 		menu
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_POWER, SDLK_POWER));		//	 		power
	m_KeyCodeMap.insert(std::map<InputKeyCode,SDLKey>::value_type
	(INPUTK_EURO, SDLK_EURO));		//	 		euro
	return true;
}

void SDLInputManager::terminateDirectInput()
{
}

void SDLInputManager::pollKeyboard()
{
}

void SDLInputManager::pollJoystick()
{
}
